home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Day Cry
/
Day Cry CD.bin
/
oh_towns
/
ugoku
/
src.lzh
/
MOVREC
/
MRCXFRM.C
< prev
next >
Wrap
Text File
|
1994-06-01
|
17KB
|
720 lines
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <winb.h>
#include <te.h>
#include <fntb.h>
#include <gui.h>
#include <file_dlg.h>
#include <tifflib.h>
#include <egb.h>
#include <mos.h>
#include <snd.h>
//#include "video.h"
#include "ugoku.h"
#include "old_mov.h"
#include "mrcdef.h"
extern int mouseSwCheck() ;
extern int errorCheck( int ) ;
extern char *guiEgbPtr ; /* EGB é╠âÅü[âNâAâhâîâX */
extern char *rbuf ; /* Ä⌐ë╞É╗é╠âÅü[âNâAâhâîâX */
extern char *bbuf ; /* Ä⌐ë╞É╗é╠âÅü[âNâAâhâîâX */
extern int baseDialogId ;
int frmDialogId[9] = -1 ;
int frmNumNumId = -1 ;
int frmMesId[37] = -1 ;
int frmSizeNumId = -1 ;
int frmNextBtnId[2] = -1 ;
int frmJmpNumId = -1 ;
int frmJmpBtnId = -1 ;
int frmSaveBtnId = -1 ;
int frmDspBtnId = -1 ;
int frmWaitNumId = -1 ;
int frmLoopNumId = -1 ;
int frmTIconId = -1 ;
int frmNumId[16] = -1 ;
int frmBtnId[4] = -1 ;
int frmCanBtnId = -1 ;
static FILE *fp;
static char movFileName[100] ;
static int rect[4] ;
static char fileName[10][16] ;
static int ch71Flag ;
static int totalFrame ;
static int prtFrame ;
static int prtFile ;
static int headPoint ;
static int jumpFrame = 0 ;
static int error ;
static int frameSize ;
static int frameWait ;
static int frameLoop ;
static int frameSnd[16] ;
static char tifPath[80] = '\0' ;
editFrame( namemov, fname, ch71 )
char *namemov ;
char fname[][16] ;
int ch71 ;
{
extern int r_waku_del() ;
char head[256];
int i, j ;
// int movframe, movx0, movy0, movx1, movy1, movwait ;
int var, min, max, delta, ptColumn ;
// int prt, len, page ;
sv01:
for( i=0 ; i<80 ; i++ )
{
movFileName[i] = namemov[i] ;
if( namemov[i] == '\0' )break ;
}
for( i=0 ; i<10 ; i++ )
{
for( j=0 ; j<16 ; j++ )
{
fileName[i][j] = fname[i][j] ;
if( fileName[i][j] == '\0' )break ;
}
}
ch71Flag = ch71 ;
for( i=0 ; i<6 ; i++ ){ /* write protect é╠ÅΩìç6ë±òKùv */
if( ( fp = fopen( namemov, "r+b" ) ) != NULL )goto sv0A;
}
return 2;
sv0A:
fseek( fp, 0, SEEK_SET );
if( fread( head, 256, 1, fp ) < 1 ){
fclose( fp );
return 58;
}
/* ò\Īâpâlâï âAâ^âbâ` */
MMI_SendMessage( frmDialogId[0], MM_ATTACH, 1, baseDialogId ) ;
/* ò\Īâpâlâïé╓âfü[â^é≡ô]æù */
if( ch71Flag )
MMI_SendMessage( frmMesId[0], MM_SETMSG, 1, "âTâEâôâh 3" ) ;
else
MMI_SendMessage( frmMesId[0], MM_SETMSG, 1, "ë╣ É║" ) ;
MMI_SendMessage( frmJmpNumId, MM_GETNUMBOX, 5,
&var, &min, &max, &delta, &ptColumn ) ;
MMI_SendMessage( frmJmpNumId, MM_SETNUMBOX, 5,
var, min, 99999, delta, ptColumn ) ;
for( i=0 ; i<4 ; i++ )
MTL_setAtrObj( frmBtnId[i], (MS_EVMOSONL40 | MS_EVDRAGOUTL40) ) ;
MMI_SendMessage( frmDialogId[0], MM_SHOW, 0 ) ; /* î⌐é╣éΘ */
rect[0] = WORD( head + 32 ); rect[1] = WORD( head + 34 ); /* ì└òW */
rect[2] = WORD( head + 36 ); rect[3] = WORD( head + 38 );
if( rect[0]==0 && rect[1]==0 && rect[2]==0 && rect[3]==0 )
{
rect[2] = 319;
rect[3] = 239;
}
frame_graph_init0( rect[0],rect[1],rect[2],rect[3] ) ;
prtFile = 256; prtFrame = -1; totalFrame = DWORD( head + 12 );
error = editFrameJump( 1 ) ;
EGB_displayPage(guiEgbPtr,1,3);
r_waku_clear3( rect[2]-rect[0]+1, rect[3]-rect[1]+1, 1 ) ;
if( error == NOERR )
{
SND_elevol_mute( 0x03 ) ;
MMI_ExecSystem() ; /* Dialogò\Īé╓ÑÑÑâCâxâôâgâïü[âv */
}
SND_elevol_mute( 0x00 ) ;
if( error )
errorCheck( error ) ;
r_waku_del() ;
EGB_displayPage(guiEgbPtr,1,2);
MMI_SendMessage( frmDialogId[0], MM_ERASE, 0 ) ;
MMI_SendMessage( frmDialogId[0], MM_DETACH, 0 ) ;
fclose( fp ) ;
return NOERR ;
}
/* initDataIRCFRM:frmNextBtnId[0]:MJ_DBUTTONL40é╠î─é╤Åoé╡è╓Éö */
/* initDataIRCFRM:frmNextBtnId[1]:MJ_DBUTTONL40é╠î─é╤Åoé╡è╓Éö */
int frmNextFunc(kobj, messId, argc, pev, trigger)
int kobj ;
int messId ;
int argc ;
EVENT *pev ;
int trigger ;
{
int i ;
SND_pcm_play_stop( 71 );
if( kobj == frmNextBtnId[0] )
{
WORD( bbuf+12 ) = frameWait ;
WORD( bbuf+14 ) = frameLoop ;
for( i=0 ; i<16 ; i++ )
BYTE( bbuf+16 + i ) = frameSnd[i] ;
fseek( fp, headPoint, SEEK_SET );
fwrite( bbuf, 32, 1, fp );
fseek( fp, prtFile, SEEK_SET );
}
if( prtFrame >= (totalFrame-1) )
{
prtFile = 256 ;
prtFrame = -1 ;
fseek( fp, 256, SEEK_SET );
}
error = editFrameJump( 1 ) ;
if( error )
MMI_SetHaltFlag( TRUE ) ;
return NOERR ;
}
/* initDataIRCFRM:frmJmpNumId:MJ_NUMBOXL40é╠î─é╤Åoé╡è╓Éö */
/* initDataIRCFRM:frmJmpBtnId:MJ_DBUTTONL40é╠î─é╤Åoé╡è╓Éö */
int frmJmpFunc(kobj, messId, argc, pev, trigger)
int kobj ;
int messId ;
int argc ;
EVENT *pev ;
int trigger ;
{
if( kobj == frmJmpNumId )
{
int var, min, max, delta, ptColumn ;
MMI_SendMessage( kobj, MM_GETNUMBOX, 5,
&var, &min, &max, &delta, &ptColumn ) ;
jumpFrame = var ;
}
else if( kobj == frmJmpBtnId )
{
prtFile = 256 ;
prtFrame = -1 ;
fseek( fp, 256, SEEK_SET );
error = editFrameJump( jumpFrame + 1 ) ;
if( error )
MMI_SetHaltFlag( TRUE ) ;
}
return NOERR ;
}
/* initDataIRCFRM:frmSaveBtnId:MJ_DBUTTONL40é╠î─é╤Åoé╡è╓Éö */
int frmSaveFunc(kobj, messId, argc, pev, trigger)
int kobj ;
int messId ;
int argc ;
EVENT *pev ;
int trigger ;
{
extern int fileSelector( char *, char **, char *, char *, char * );
extern int file_kakuchousi_set( char *, char *, char * ) ;
char *ExtStr[] = { "*.TIF", NULL } ;
char path[100] ;
int i, ret, error ;
/* âüâjâàü[é╞â{â^âôé≡Ägéªé╚éóéµéñé╔é╖éΘ */
MTL_setAtrObj( frmDialogId[0], MS_DSPONLYL40 ) ;
error = 0 ;
ret = fileSelector(tifPath, ExtStr,
"éséhéeéeâZü[âu", "Ä└ ìs", "ĵ Å┴");
if( ret )
goto v10 ;
else
{
/* name , kakuchou[ègÆúÄq(.***)] ü¿ fullname = name + kakuchou */
error = file_kakuchousi_set( path, tifPath, ".TIF" ) ;
if( error == NOERR )
{
for( i=0 ; i<80 ; i++ )
tifPath[i] = path[i] ;
}
}
if( error == NOERR )
{
error = saveTif( tifPath ) ;
}
v10:
/* âüâjâàü[é╞â{â^âôé≡ÄgéªéΘéµéñé╔û▀é╖ */
MTL_resetAtrObj( frmDialogId[0], (~MS_DSPONLYL40) ) ;
if( error )
errorCheck( error ) ;
return NOERR ;
}
saveTif( fullname )
char *fullname;
{
FILE *fps;
int size,i;
int ax1, ay1, ax2, ay2, temp;
char para[64] ;
struct TIFF1{ /* 10Byte */
int id, ifd1;
short offset;
} head1[] = { 0x2a4949, 8, 15 };
struct TIFF2{ /* 192Byte */
short tag, type;
int length, data;
} head2[] =
{ { 0x0ff, 3, 1, 1 },
{ 0x100, 3, 1, 320 },
{ 0x101, 3, 1, 240 },
{ 0x102, 3, 1, 16 },
{ 0x103, 3, 1, 1 },
{ 0x106, 3, 1, 1 },
{ 0x10a, 3, 1, 1 },
{ 0x111, 4, 1, 0x200 },
{ 0x115, 3, 1, 1 },
{ 0x116, 4, 1, 0xf0 },
{ 0x117, 4, 1, 320*240*2 },
{ 0x119, 3, 1, 32767 },
{ 0x11a, 5, 1, 0x1f0 },
{ 0x11b, 5, 1, 0x1f8 },
{ 0x11c, 3, 1, 1 },
{ 0, 0, 0, 0 }
};
char head3[294]; /* 294Byte */
int head4[] = { 0x4b, 2, 0x4b, 2 }; /* 16Byte */
ax1 = 0; ay1 = 0; ax2 = 319; ay2 = 239;
size = ( ax2 - ax1 + 1 )*( ay2 - ay1 + 1 )*2;
DWORD( ((char *)head2)+0x14 ) = ax2 - ax1 + 1;
DWORD( ((char *)head2)+0x20 ) = ay2 - ay1 + 1;
DWORD( ((char *)head2)+128 ) = size;
for( i=0 ; i<294 ; i++ )head3[i] = (char)0;
for( i=0 ; i<6 ; i++ ){ /* disk write protect é╠ÅΩìç6ë±òKùv */
if( ( fps = fopen( fullname, "wb" ) ) != NULL )goto save1;
}
return 2;
save1:
EGB_writePage(guiEgbPtr,0);
DWORD( para + 0 ) = (unsigned int)rbuf ;
WORD( para + 4 ) = 0x14 ;
WORD( para + 6 ) = ax1 ;
WORD( para + 8 ) = ay1 ;
WORD( para + 10) = ax2 ;
WORD( para + 12) = ay2 ;
EGB_getBlock( guiEgbPtr, para ) ;
EGB_writePage(guiEgbPtr,1);
fwrite( (char *)head1, 10, 1, fps );
fwrite( (char *)head2, 192, 1, fps );
fwrite( (char *)head3, 294, 1, fps );
fwrite( (char *)head4, 16, 1, fps );
fwrite( rbuf, size, 1, fps );
temp = ferror( fps );
fclose( fps );
if( temp ){
remove( fullname ); /* disk full */
return 2;
}
return 0;
}
/* initDataIRCFRM:frmDspBtnId:MJ_DBUTTONL40é╠î─é╤Åoé╡è╓Éö */
int frmDspFunc(kobj, messId, argc, pev, trigger)
int kobj ;
int messId ;